﻿using LS.Screening.Application;
using LS.Screening.Infrastructure;

namespace LS.Screening.Report.Host
{
    [DependsOn(typeof(ApplicationModule))]
    public class WebModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            base.ConfigureServices(context);
            context.Services.AddControllers(options =>
            {
                options.Filters.Add<PropertyInjectionFilter>();
            });
            context.Services.AddSingleton<PropertyInjectionFilter>();
            context.Services.AddEndpointsApiExplorer();
            context.Services.AddSwaggerGen();
        }

        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            base.OnApplicationInitialization(context);

            if (context.App.Environment.IsDevelopment())
            {
                context.App.UseSwagger();
                context.App.UseSwaggerUI();
            }
            context.App.UseAuthorization();
            context.App.MapControllers();
            context.App.Run();
        }
    }
}
